<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			var _this = this;
			var connectSocketInit = function() {
				uni.connectSocket({
					// #ifdef APP-PLUS
					url: "ws://47.243.163.120:2346",
					// #endif
					// #ifdef H5
					url: "ws://47.243.163.120:2346",
					// #endif
					success(data) {
						_this.globalData.klineHasSocket = true;
						console.log("websocket连接成功" + JSON.stringify(data));
						uni.preloadPage({
							url: "/pages/heyue/heyue"
						});

						uni.onSocketOpen((res) => {
							uni.sendSocketMessage({
								data: JSON.stringify({
									symbol: (_this.icon ? _this.icon : 'btc') +
										'usdt',
									period: _this.kTime,
									size: "100"
								}),
								complete(res) {
									console.log(JSON.stringify(res))
								}
							})
						})
					},
				});
				uni.onSocketError(function(res) {
					console.log(JSON.stringify(res));
					connectSocketInit()
				});
				uni.onSocketClose(() => {
					console.log("socket已经被关闭了")
					connectSocketInit()
				})
			}
			connectSocketInit();
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		globalData: {
			klineHasSocket: false
		}
	}
</script>



<style>
	@import url("./static/utils/css/common.css");

	/*每个页面公共css */
	page {
		min-height: 100%;
		width: 100vw;
		background-color: #101529;
		color: #f8fcfd;
	}

	.bg_f2 {
		background-color: #F2F2F2;
	}

	.color_bgup {
		background-color: #e13b60;

	}

	.color_bgdown {
		background-color: #16df6b;
	}

	.color_up {
		color: #16df6b;
	}

	.color_down {
		color: #e13b60;
	}

	.pub_color {
		color: #4e5ac6;
	}

	.pub_bg {
		background-color: #0a37d2;
	}

	.tab_ac {
		border-bottom: 2px solid #0066ee;
	}

	.pub_btn {
		background-color: #0a37d2;
		color: #FFFFFF;
		text-align: center;
	}

	.B_1_gray {
		border: 1px solid #cecece;
	}

	.line_bom {
		border-bottom: 1px solid #CECECE;
	}
</style>
